<%@ page contentType="text/html; charset=UTF-8" language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> 
<%@ include file="/WEB-INF/jsp/common/taglibs.jsp" %>

<script src="${appPath }/resource/js/validate_forminp.js" type="text/javascript" ></script>
<script>

function chgRowPerPage(n){
	$("#ChgRowPerPageLoadingImg").show();
	$('#rowsPerPage').val(n);
	pageTo(1);
}


function pageTo(n){
	$('#requery').val("false");
	$('#nowPage').val(n);
	$.post("${appPath}/form/research/page.htm",$('#PageForm').serialize(),function(data){
		$("#querylist").html(data);
		$("#ChgRowPerPageLoadingImg").hide();
	});
}

function reload(){
	$("#ChgRowPerPageLoadingImg").show();
	$('#requery').val("true");
	$('#nowPage').val("1");
	$.post("${appPath}/form/research/page.htm",$('#PageForm').serialize(),function(data){
		$("#querylist").html(data);
		$("#ChgRowPerPageLoadingImg").hide();
	});
}

var CURRENT_SEQNO = null;
function toResearch(seq,rec){
	CURRENT_SEQNO = seq;	
	$("#BtnBackList").hide();
	$("#BtnSubmit").show();
	$("#ResearchAndAnalysisForm :checkbox").removeAttr("disabled"); 
	$("#ResearchAndAnalysisForm textarea").removeAttr("disabled");
	
	document.getElementById("ResearchAndAnalysisForm").reset();
	$("#BtnBackList").hide();
	$("#BtnSubmit").show();	
	
	$("#Span_Rec_No").html(rec);	
	$("#DIS_ROWPERPAGE").fadeOut("fast");
	$("#querylist").fadeOut("fast",function(){
		$("#view").fadeIn("fast");
	});
	$("#ResearchAndAnalysisForm input[name=rec_no]").val(rec);
}

function _submit(){	
	/*
	showMessage("研析輸入成功",1);
	$("#ResearchAndAnalysisForm input").prop("disabled",true);
	$("#ResearchAndAnalysisForm textarea").prop("disabled",true);
	
	$("#BtnBackList").show();
	$("#BtnSubmit").hide();

	*/
	$.post("${appPath}/form/page/research/add.htm",$('#ResearchAndAnalysisForm').serialize(),function(data){
		if(data){
			showMessage("研析輸入成功",1);
			$("#ResearchAndAnalysisForm :checkbox").prop("disabled",true);
			$("#ResearchAndAnalysisForm input[type=text]").prop("disabled",true);
			$("#ResearchAndAnalysisForm textarea").prop("disabled",true);	
			
			var OKimg = "<img src='${appPath }/resource/image/1317488036_ok.gif' style='vertical-align:middle;'/>";			
			$("#TD_" + CURRENT_SEQNO).html(OKimg);			
			//$("#LIST_FLOW_" + CURRENT_SEQNO).html("<span style='color:red;'>已研析</span>");
			$("#LIST_FLOW_" + CURRENT_SEQNO).html("<img src='${appPath }/resource/image/switch03.png'/>");
			$("#BtnBackList").show();
			$("#BtnSubmit").hide();
			CURRENT_SEQNO = null;			
		}else{
			showMessage("研析輸入失敗",2);
		}
	});
}

function showDesc(obj){
	var _isChecked = $("#ResearchAndAnalysisForm input[name="+obj.name+"]").prop("checked");
	$("#ResearchAndAnalysisForm input[name="+obj.name+"_desc]").prop("disabled",!_isChecked);	
	document.getElementById("ResearchAndAnalysisForm").elements[obj.name+"_desc"].focus();
}

</script>
<div id="page">
	<div id="page-bgtop">
		<div id="page-bgbtm">
			<div id="content">
				<div class="post">
					<%-- 
					<h2 class="title inner">我的表單<span id="loading_1" style="padding-left:20px;display:none;"><img src="${appPath }/resource/image/ajax-loader.gif" /></span></h2>
					
					<div style="clear: both;">&nbsp;</div> 
					--%>					
					<div class="entry">		
						
					<c:if test="${fn:length(PageForm.obj) == 0}" >
						<div style="padding-top:5px;">
							<table style="border: 1px solid #C0C0C0;">	
								<tr>
									<td>
										<div style="padding:20px;font-size: 16px;font-weight: 300;letter-spacing: 4px;">
											<img src="${appPath }/resource/image/1320894006_Problem.png" style="vertical-align:middle;"/>
											<span style="color: #3B5998;">目前尚無研析表單資料</span>
										</div>
									</td>
								</tr>
							</table>
						</div>
					</c:if>
					
					<c:if test="${fn:length(PageForm.obj) != 0}" >
						<table style="width:800px;" id="DIS_ROWPERPAGE">	
							<tr>
								<td style="text-align: right">
									<span id="ChgRowPerPageLoadingImg" style="display:none">
										<img src="${appPath }/resource/image/ajax-loader.gif" />
									</span>
									
									
									<a href="javascript:void(0);" onclick="reload();">
										<img src="${appPath }/resource/image/1322032052_reload_all_tabs.png" border="0" style="vertical-align: middle;padding-right:10px;">
									</a>
									<select class="bar_1" style="width:50px;" onchange="chgRowPerPage(this.value);">
										<%-- <option value="5" <c:if test="${ROWPERPAGE == 5 }">selected</c:if>>5</option> --%>
										<option value="10" <c:if test="${ROWPERPAGE == 10 }">selected</c:if>>10</option>
										<option value="20" <c:if test="${ROWPERPAGE == 20 }">selected</c:if>>20</option>
										<option value="50" <c:if test="${ROWPERPAGE == 50 }">selected</c:if>>50</option>
										<option value="100" <c:if test="${ROWPERPAGE == 100 }">selected</c:if>>100</option>
									</select>
								</td>
							</tr>
						</table>
							
						<div id="querylist"><%@ include file="list.jsp" %></div>
						
						<div id="view" style="display:none"><%@ include file="form.jsp" %></div>
					</c:if>
						
						
					</div>					
				</div>
				<div style="clear: both;">&nbsp;</div>
			</div>
			<!-- end #content -->			
			<%@ include file="/WEB-INF/jsp/common/submenu02.jsp" %>			
			<div style="clear: both;">&nbsp;</div>
		</div>
	</div>
</div>
<!-- end #page -->